/**
 * Created with IntelliJ IDEA.
 * User: bugger
 * Date: 1/10/14
 * Time: 5:06 PM
 * To change this template use File | Settings | File Templates.
 */
import java.util.TreeSet;

public class PrimeFactors {

  public static void main(String[] args){
    PrimeFactors pf = new PrimeFactors();
    System.out.println(pf.generate(1));
    System.out.println(pf.generate(30));
  }

  private TreeSet generate(int number){
    TreeSet<Integer> factors = new TreeSet<Integer>();
    int last_high_factor = number;

    int check = 2;
    while (check < last_high_factor){
      if (number%check == 0){
        factors.add(check);
        factors.add(number/check);
        last_high_factor = number/check;
      }
      check += 1;
    }
    return factors;
  }
}
